﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;

namespace Enough.Converter
{
    //[ValueConversion(typeuof(Color), typeof(Brush))]
    public class ColorToBrushConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, string culture)
        {
            string color = value.ToString();
            byte R = System.Convert.ToByte(color.Substring(1, 2), 16);
            byte G = System.Convert.ToByte(color.Substring(3, 2), 16);
            byte B = System.Convert.ToByte(color.Substring(5, 2), 16);
            SolidColorBrush scb = new SolidColorBrush(Color.FromArgb(255, R, G, B));
            return scb;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string culture)
        {
            return ((SolidColorBrush)value).Color;
        }

    }
}
